import { createSSRApp } from "vue";
import App from "./App.vue";

//引入uviewPlus
import uviewPlus from "uview-plus";
//引入api
import api from "@/api/index.js";
//引入store
import store from "@/store";
import { createPinia } from "pinia";
import { createPersistedState } from "pinia-plugin-persistedstate";

// 引入全局过滤器
import { filters } from "@/utils/filters.js";

export function createApp() {
    const app = createSSRApp(App);

    // 配置全局uviewPlus
    app.use(uviewPlus);

    // 配置全局api
    app.config.globalProperties.$api = api;

    //配置全局Store
    const pinia = createPinia();
    pinia.use(
        createPersistedState({
            storage: localStorage,
            auto: true, // 启用所有Store默认持久化
        })
    );
    app.use(pinia);
    app.config.globalProperties.$store = store;

    //配置全局过滤器
    app.config.globalProperties.$filters = filters;

    return {
        app,
    };
}
